package tree2;

import java.util.HashMap;
import java.util.Map;

public class SubNode {
	private int key;
	
	/**
	 * Left : Document ID
	 * Right : Term Freq
	 */
	private Map<Integer, Integer> postingList;

	public SubNode(int key, int idDoc) {
		this.key = key;
		postingList = new HashMap<Integer, Integer>();
		postingList.put(idDoc, 1);
	}

	public int getKey() {
		return key;
	}

	public Map<Integer, Integer> getPostingList() {
		return postingList;
	}

	public void addIdDoc(int idDoc){
		if(postingList.containsKey(idDoc)){
			postingList.put(idDoc, postingList.get(idDoc)+1);
		} else {
			postingList.put(idDoc, 1);
		}
	}
	
	public void printSubNode(){
		System.out.print(getKey()+" : ");
		for(int id : postingList.keySet()){
			System.out.print(id+",");
			System.out.print(postingList.get(id)+"->");
		}
	}
}
